var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2PTConfig = require("PTConfig");
var $2BundleManager = require("BundleManager");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_UIPLoadingFirst = /* */function (_cc$Component28) {
  function _ctor() {
    var _this111;
    babel_classCallCheck(this, _ctor);
    _this111 = _callSuper(this, _ctor, arguments);
    _this111.boat = null;
    _this111.progressBar = null;
    _this111.softInfo = null;
    _this111.logo = null;
    _this111.loaded = false;
    _this111._startLoad = false;
    _this111._startTime = 0;
    _this111.cancelPromise = false;
    _this111.loadSuccessNum = 0;
    return _this111;
  }
  babel_inherits(_ctor, _cc$Component28);
  return babel_createClass(_ctor, [{
    key: "onEnable",
    value: function onEnable() {
      this.showLevelsUi();
      this.unscheduleAllCallbacks();
    }
  }, {
    key: "onLoad",
    value: function onLoad() {
      this.cancelPromise = false;
      this.syncSoftInfo();
    }
  }, {
    key: "syncSoftInfo",
    value: function syncSoftInfo() {
      var _this112 = this;
      if (cc.sys.isBrowser) {
        $2PTConfig.default.GameAppId = "tt84def2631be94d1f02";
      } else {
        $2PTConfig.default.GameAppId = 'wx504280e7f29e9878';
      }
      
      this.softInfo.string = "";

      var e = "https://oppomini.eqmobi.com/stonesh/wll/RoyalMatch/logo/".concat($2PTConfig.default.GameAppId, ".png");
      cc.assetManager.loadRemote(e, {
        ext: ".png"
      }, function (e, t) {
        console.log('e',e,'t',t)
        if (e) {
          return void cc.error(e);
        }
        var n = new cc.SpriteFrame(t);
        console.log("-------------logo加载完成-------------", n);
        _this112.cancelPromise || (_this112.logo.spriteFrame = n);
      });
    }
  }, {
    key: "showLevelsUi",
    value: function showLevelsUi() {
      this._startLoad = true;
      this._startTime = 0;
      this.boat.x = -18;
      this.progressBar.progress = 0;
    }
  }, {
    key: "lateUpdate",
    value: function lateUpdate(e) {
      if (this._startLoad) {
        this._startTime += e;
        if (this._startTime >= 1) {
          if (this._startTime >= 15) {
            this._startLoad = false;
            console.log("资源加载超时，请检查网络");
            this.hide();
          }
        } else {
          var _e62 = .05 * (1 - this.progressBar.progress);
          this.progressBar.progress += _e62;
          this.boat.x = 380 * this.progressBar.progress;
        }
      }
    }
  }, {
    key: "loadAll",
    value: function loadAll(e) {
      var _this113 = this;
      this._startLoad = true;
      this._startTime = 0;
      this.boat.x = -18;
      this.progressBar.progress = 0;
      this.loadBundle(function () {
        if (1 == _this113.loadSuccessNum) {
          e && e();
          _this113.hide();
        }
      }, this);
    }
  }, {
    key: "loadBundle",
    value: function loadBundle(e, t) {
      console.log("loadBundle:  Res");
      var n = new Date().getTime();
      cc.assetManager.loadBundle("Res", function (o, i) {
        if (o) {
          console.log("err:", o);
        } else {
          var _o120 = new Date().getTime() - n;
          console.log("Res文件夹加载耗时:", _o120, "毫秒");
          $2BundleManager.default.getInstance().resBundle = i;
          console.log("加载成功:Res");
          t.loadSuccessNum++;
          e && e();
        }
      });
    }
  }, {
    key: "hide",
    value: function hide() {
      this.node.destroy();
      this.node.removeFromParent();
      this.cancelPromise = true;
    }
  }]);
}(cc.Component);
cc__decorate([ccp_property({
  type: cc.Node,
  tooltip: "船"
})], def_UIPLoadingFirst.prototype, "boat", undefined);
cc__decorate([ccp_property({
  type: cc.ProgressBar,
  tooltip: "进度条"
})], def_UIPLoadingFirst.prototype, "progressBar", undefined);
cc__decorate([ccp_property(cc.Label)], def_UIPLoadingFirst.prototype, "softInfo", undefined);
cc__decorate([ccp_property(cc.Sprite)], def_UIPLoadingFirst.prototype, "logo", undefined);
def_UIPLoadingFirst = cc__decorate([ccp_ccclass], def_UIPLoadingFirst);
exports.default = def_UIPLoadingFirst;